package cd.safe.school.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetWorkUtil {
	// 判断当前网络连接
	public static boolean NetworkStateCheck(Context context) {

		ConnectivityManager cnm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);

		if (cnm.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
				|| cnm.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) {
			return true;
		} else {
			return false;
		}
	}

	public static String today(String a) {
		String s = "";
		try {
			Date d = new SimpleDateFormat("yyyyMMddhhmm").parse(a);
			s = new SimpleDateFormat("yyyy-MM-dd hh:mm").format(d);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return s;

	}

}
